﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Linq.Expressions;

namespace Htse.Blue.Logic.Validation
{
	public class ModelStateWrapper<TModel> : IValidationDictionary<TModel> where TModel : class
	{
		private ModelStateDictionary _modelState;

		public ModelStateWrapper(ModelStateDictionary modelState)
		{
			_modelState = modelState;
		}

		public IValidationDictionary<TModel> AddError(string key, string errorMessage)
		{
			_modelState.AddModelError(key, errorMessage);

			return this;
		}

		public IValidationDictionary<TModel> AddError(string key1, string key2, string errorMessage)
		{
			_modelState.AddModelError(key1, errorMessage);
			_modelState.AddModelError(key2, string.Empty);

			return this;
		}

		public bool IsValid
		{
			get { return _modelState.IsValid; }
		}
	}
}
